//
//  DeviceManager.m
//  Doctor1.0
//
//  Created by mk on 15/8/5.
//  Copyright (c) 2015年 cocoa-mk. All rights reserved.
//

#import "DeviceManager.h"
#include <sys/types.h>
#include <sys/sysctl.h>
@implementation DeviceManager
+ (NSString*)getDeviceVersion

{
    
    size_t size;
    
    sysctlbyname("hw.machine",NULL, &size, NULL,0);
    
    char *machine = (char *)malloc(size);
    
    sysctlbyname("hw.machine", machine, &size,NULL, 0);
    
    NSString *platform = [NSString stringWithCString:machine encoding:NSUTF8StringEncoding];
    
    free(machine);
    
    return platform;
    
}


+ (NSString *)getPlatformString

{
    NSString *platform = [self getDeviceVersion];
    
    if ([platform isEqualToString:@"iPhone1,1"]) return @"iPhone1";
    
    if ([platform isEqualToString:@"iPhone1,2"]) return @"iPhone3";
    
    if ([platform isEqualToString:@"iPhone2,1"]) return @"iPhone3GS";
    
    if ([platform isEqualToString:@"iPhone3,1"]) return @"iPhone4";
    
    if ([platform isEqualToString:@"iPhone3,2"]) return @"iPhone4";
    
    if ([platform isEqualToString:@"iPhone3,3"]) return @"iPhone4";
    
    if ([platform isEqualToString:@"iPhone4,1"]) return @"iPhone4s";
    
    if ([platform isEqualToString:@"iPhone5,1"]) return @"iPhone5";
    
    if ([platform isEqualToString:@"iPhone5,2"]) return @"iPhone5";
    
    if ([platform isEqualToString:@"iPhone5,3"]) return @"iPhone5C";
    
    if ([platform isEqualToString:@"iPhone5,4"]) return @"iPhone5C";
    
    if ([platform isEqualToString:@"iPhone6,1"]) return @"iPhone5S";
    
    if ([platform isEqualToString:@"iPhone6,2"]) return @"iPhone5S";
    
    if ([platform isEqualToString:@"iPhone7,1"]) return @"iPhone6";
    
    if ([platform isEqualToString:@"iPhone7,2"]) return @"iPhone6Plus";
    
    
    if ([platform isEqualToString:@"iPhone Simulator"] || [platform isEqualToString:@"x86_64"]) return @"iPhone Simulator";
   // DLog(@"%@", platform);
    return platform;
    
}
@end
